import numpy as np
import csv

def load_data(file_path):
    data = np.genfromtxt('scores.csv',delimiter=',',skip_header=1)
    return data[:,2:]

    """
    Load CSV data into NumPy array
    Columns: student_id, name, math_score, english_score, python_score
    Return: 2D NumPy array of shape (students, 3) containing scores
    """
    # 加载CSV数据到NumPy数组
    # 列：student_id, name, math_score, english_score, python_score
    # 返回：形状为(学生数, 3)的二维数组，包含三科成绩
    pass

def calculate_statistics(data):
    means = np.round(np.mean(data,axis=0),1)
    medians = np.round(np.median(data,axis=0),1)
    variances = np.round(np.var(data,axis=0),1)
    stds = np.round(np.std(data,axis=0),1)
    return {
        'means': means,
        'medians': medians,
        'variances': variances,
        'stds': stds
    }

    """
    Calculate required statistics for each subject
    Return: Dictionary containing {
        'means': [math_mean, english_mean, python_mean],
        'medians': [math_median, english_median, python_median],
        'variances': [math_var, english_var, python_var],
        'stds': [math_std, english_std, python_std]
    }
    """
    # 计算每科的统计指标
    # 返回：包含平均值、中位数、方差、标准差的字典
    pass

def print_results(stats):
    subjects = ["Math", "English", "Python"]
    math_avg, eng_avg, py_avg = stats['means']
    math_med, eng_med, py_med = stats['medians']
    math_var, eng_var, py_var = stats['variances']
    math_std, eng_std, py_std = stats['stds']
    print(f"{subjects[0]}:")
    print(f"Average:{math_avg}")
    print(f"Median:{math_med}")
    print(f"Variance:{math_var}")
    print(f"Standard Deviation:{math_std}")

    print(f"{subjects[1]}:")
    print(f"Average:{eng_avg}")
    print(f"Median:{eng_med}")
    print(f"Variance:{eng_var}")
    print(f"Standard Deviation:{eng_std}")

    print(f"{subjects[2]}:")
    print(f"Average:{py_avg}")
    print(f"Median:{py_med}")
    print(f"Variance:{py_var}")
    print(f"Standard Deviation:{py_std}")
    best_subject_index = np.argmax(stats['means'])
    most_consistent_subject_index = np.argmin(stats['stds'])
    print(f"Best Subject:{subjects[best_subject_index]}")
    print(f"Most Consistent Subject (Lowest Std):{subjects[most_consistent_subject_index]} ({stats['stds'][most_consistent_subject_index]})")
    """
    Print results in EXACTLY this format:
    Math:
        Average: 85.0
        Median: 86.0
        Variance: 25.0
        Standard Deviation: 5.0
    English:
        ...
    Best Subject: Math
    Most Consistent Subject (Lowest Std): English (4.2)
    """
    # 严格按指定格式打印结果
    # 输出示例格式见上方注释
    pass

def main():
    data = load_data('scores.csv')
    stats = calculate_statistics(data)
    print_results(stats)

if __name__ == "__main__":
    main()